// Copyright 2009, Google Inc. All Rights Reserved.
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0 
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * This code sample retrieves the list of datamaps for specified profile.
 *
 * To generate an XML Web Service Proxy Class you need to:
 * 1. Run Web Services Description Language Tool Wsdl.exe from "$Microsoft Visual Studio Install Directory$\SDK\v2.0\Bin".
 *    wsdl http://server[:port]/services/v1/reportservice?wsdl /language:CS /protocol:SOAP /namespace:SampleCode.com.google.DataAPI.ReportService /out:ReportService.cs
 * 2. Copy obtained ReportService.cs into the project folder and add it to the project.
 */

using SampleCode.com.google.DataAPI.ReportService;

using System;

namespace ReportServiceGetTableListSOAP
{
	public class GetTableList
	{
		// Provide login information.
		private const string login = "YOUR_LOGIN";
		private const string password = "YOUR_PASSWORD";
		private const int profileId = 16;

		static void Main()
		{
			try
			{
				// Set up service connection.
				reportservice reportService = new reportservice();
				// Get table list.
				Table[] tables = reportService.getTableList(login, password, profileId);
				// Display tables info.
				foreach (Table table in tables)
					DisplayTable(table);
			}
			catch (Exception e)
			{
				Console.WriteLine(e);
			}
		}

		private static void DisplayTable(Table table)
		{
			Console.WriteLine("Table id is \"" + table.tableId + "\", ");
			// Display the table dimensions.
			Console.WriteLine("dimensions are:");
			foreach (string dimension in table.dimensions)
				Console.WriteLine(" \t\"" + dimension + "\", ");
			// Display the table metrics.
			Console.WriteLine("metrics are:");
			foreach (string metric in table.metrics)
				Console.WriteLine("\t\"" + metric + "\", ");
		}
	}
}
